package com.sniff.atp.modules.test.smallTool;


import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.sniff.atp.utils.HttpClientUtil;
import com.sniff.atp.utils.JsonUtil;

/**
 * @ProjectName: sniff-atp
 * @Package: com.sniff.atp.modules.test.smallTool
 * @ClassName: UpdateAbnornalOrder
 * @Description: 更新异常采购单
 * @Author: zss
 * @CreateDate: 2024/1/15 10:25
 * @UpdateDate: 2024/1/15 10:25
 * @Version: 1.0
 */
public class UpdateAbnornalOrder {

    public static void main(String[] args) {


        String a = "YCCGD24012204000842,YCCGD24022203000642,YCCGD24022106001358,YCCGD24022106001342,YCCGD24022106001348,YCCGD24022106001352,YCCGD24021811000160,YCCGD24021810000114,YCCGD24021801000426,YCCGD24021801000430,YCCGD24013004001030,YCCGD24013004001034,YCCGD24013103000902,YCCGD24013102000796,YCCGD24013001000444,YCCGD24013103000892,YCCGD24013103000894,YCCGD24013001000446,YCCGD24013105001072,YCCGD24013102000792,YCCGD24013102000790,YCCGD24020101000470,YCCGD24020101000472,YCCGD24020102000542,YCCGD24020102000548,YCCGD24020102000532,YCCGD24020101000466,YCCGD24020101000468,YCCGD24020204000640,YCCGD24020102000546,YCCGD24013011000380,YCCGD24013003000746,YCCGD24013003000858,YCCGD24013003000856,YCCGD24013003000900,YCCGD24020107001062,YCCGD24013007001274,YCCGD24013003000904,YCCGD24013006001248,YCCGD24013004001044,YCCGD24013009000084,YCCGD24013103000890,YCCGD24020110000212,YCCGD24020110000216,YCCGD24020211000270,YCCGD24020209000068,YCCGD24020209000900,YCCGD24022105001236";

        String[] shopId = a.split(",");

        int lengthShop = shopId.length;
        int errorNumber= 0;
        String errorCode = "";
        for (int i = 0; i < lengthShop; i++) {

            System.out.println("---------------------" + i + "---------------------");
            JSONObject param = new JSONObject();
            param.put("purchasingAbnormalOrderNo", shopId[i]);
            param.put("bizType", 2);

            //异常采购单无法完结
            String result = new HttpClientUtil().doPostNeedTokenList("https://gateway-prod.theckb.com/purchase/purchase/abnormal/manualReconciliationCallback", param);
//        String result = new HttpClientUtil().doPostNeedToken("https://master-gateway.theckb.com/order/manage/platformOrderItem/specialCheckEdit", param);
            String code = JsonUtil.extractString(result, "code");
            if ("0".equals(code)) {

            } else {
                errorNumber ++;
                errorCode = errorCode.concat(shopId[i]);
                System.out.println("这个系统单号错了" + shopId[i]);
            }

            try {
                Thread.sleep(1000); // 1000毫秒 = 1秒
            } catch (InterruptedException e) {
                // 处理中断异常
            }

        }

        System.out.println("错误的次数"+ errorNumber);
        System.out.println("错误的"+ errorCode);
    }
}
